package com.ssy.lingxi.order.repository;

import com.ssy.lingxi.order.entity.BaseOrderTimeParamDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 系统能力 - 订单时间参数配置相关接口
 * @author wyx
 * @version 2.0.0
 * @date 2021-10-13
 */
@Repository
public interface BaseOrderTimeParamRepository extends JpaRepository<BaseOrderTimeParamDO, Long>, JpaSpecificationExecutor<BaseOrderTimeParamDO> {

    List<BaseOrderTimeParamDO> findAllByMemberIdAndMemberRoleIdAndParamType(Long memberId, Long memberRoleId, Integer paramType);

    int countByMemberIdAndMemberRoleIdAndShopIdAndStatusAndParamType(Long memberId, Long memberRoleId, Long shopId, Integer status, Integer paramType);

    BaseOrderTimeParamDO findFirstByMemberIdAndMemberRoleIdAndShopIdAndParamTypeAndStatus(Long memberId, Long roleId, Long shopId, Integer paramType, Integer status);

    List<BaseOrderTimeParamDO> findAllByMemberIdAndMemberRoleIdAndShopIdAndStatus(Long memberId, Long memberRoleId, Long shopId, Integer status);

    @Transactional
    void deleteAllByMemberIdAndMemberRoleIdAndParamType(Long memberId, Long memberRoleId, Integer paramType);
}
